<template>
	<view>
		<view class="" style="height: 20rpx;"></view>
		<view class="title">
			<view class="t_l">
				日期筛选：
			</view>
			<view class="t_r">
				<uni-datetime-picker @change='timechange' type="daterange" v-model="datetimerange"  rangeSeparator="-" />
			</view>
		</view>
		<view class="content" v-for="(item,index) in orderList" :key="index" @click="goorderInfo(item)">
			<view class="cont_head_flex">
				<view class="t">订单编号：{{item.orderNumber}}</view>
				<!-- 0未打印 1成功 2失败 -->
				<view class="ttype" v-if="item.printStatus == 0">未打印</view>
				<view class="ttype" v-if="item.printStatus == 1">打印成功</view>
				<view class="ttype1" v-if="item.printStatus == 2">打印失败</view>
			</view>
			<view class="con_info">
				<view class="img_l">
					<image @error='images' :src="item.productImage" mode=""></image>
				</view>
				<view class="flexc_1">
					<view class="flex_cont">
						<view class="t1">{{item.productName}}</view>
						<view class="t4">￥{{item.totalAmount}}</view>
					</view>
					<view class="flex_cont">
						<view class="t2">单价：￥{{item.productPrice}}</view>
						<view class="t2">x{{item.productCount}}</view>
					</view>
					<view class="flex_cont">
						<view class="t2">车牌：{{item.carNumber}}</view>
					</view>
				</view>
			</view>
		<!-- 	<view class="flexc_2">
				<uni-icons type="clear" size="16" color="#FF4800"></uni-icons>
				<view class="ts">
					失败原因：XXX连续中断！
				</view>
			</view> -->
			<view class="btns_flex" v-if="item.printStatus == 0 || item.printStatus == 2">
				<view class=""></view>
				<view class="btn" @click.stop="dy(item)">立即打印</view>
			</view>
		</view>
		<view class="kong" v-if="orderList.length == ''">
			<image class="img" src="../../static/kong.png" mode=""></image>
			<view class="text">
				暂无数据
			</view>
		</view>
	</view>
</template>

<script>
	import {
		orderList,dyorder
	} from '../../common/http.api.js'
	export default {
		data() {
			return {
				images:require('../../static/1.jpg'),
				datetimerange:'',
				params:{
					pageNum:1,
					pageSize:10
				},
				orderList:[]
			};
		},
		onLoad() {
			this.getlist()
		},
		methods:{
			getlist(){
				orderList(this.params).then(res=>{
					this.orderList = res.rows
				})
			},
			goorderInfo(item){
				uni.navigateTo({
					url:`/pages/my/orderInfo?id=${item.id}`
				})
			},
			dy(item){
				dyorder({id:item.id}).then(res=>{
					if(res.code == 200){
						this.getlist()
					}
				})
			},
			timechange(e){
				this.params.beginTime = e[0]
				this.params.endTime = e[1]
				this.getlist()
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F6F6F6;
	}
	.kong{
		text-align: center;
		margin-top: 180rpx;
		.img{
			width: 300rpx;
			height: 300rpx;
		}
		.text{
			color: #CCCCCC;
			text-align: center;
		}
	}
.title{
	display: flex;
	align-items: center;
	width: 702rpx;
	margin: 0rpx auto;
	.t_r{
		width: 554rpx;
	}
	.t_l{
		width: 148rpx;
		font-size: 28rpx;
		color: #000;
	}
}
.content{
	width: 702rpx;
	margin: 20rpx auto;
	background-color: #fff;
	border-radius: 20rpx;
	.cont_head_flex{
		display: flex;
		padding: 24rpx 20rpx 10rpx;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #eeeeee;
		.t{
			font-weight: 400;
			font-size: 24rpx;
			color: #A3A3A3;
		}
		.ttype{
			font-weight: 400;
			font-size: 24rpx;
			color: #797979;
		}
		.ttype1{
			font-weight: 400;
			font-size: 24rpx;
			color: #FF4800;
		}
	}
	.con_info{
		display: flex;
		padding: 20rpx 20rpx 20rpx;
		.img_l{
			width: 116rpx;
			height: 116rpx;
			image{
				width: 116rpx;
				height: 116rpx;
				border-radius: 10rpx;
			}
		}
		.flexc_1{
			margin-left: 10rpx;
			flex: 1;
		}
	}
}
.flex_cont{
	
	display: flex;
	justify-content: space-between;
	align-items: center;
	.t1{
		font-weight: bold;
		font-size: 28rpx;
		color: #282828;
	}
	.t2{
		font-weight: 400;
		font-size: 24rpx;
		color: #A3A3A3;
	}
	.t4{
		font-weight: bold;
		font-size: 35rpx;
		color: #282828;
	}
}
.flexc_2{
	width: 662rpx;
	display: flex;
	background: rgba(255,72,0,0.1);
	margin: 0 auto;
	align-items: center;
	padding: 24rpx 20rpx;
	box-sizing: border-box;
	border-radius: 10rpx;
	.ts{
		font-weight: 400;
		font-size: 24rpx;
		color: #FF4800;
		margin-left: 6rpx;
	}
}
.btns_flex{
	display: flex;
	justify-content: space-between;
	padding: 24rpx 20rpx;
	.btn{
		width: 144rpx;
		height: 56rpx;
		background: linear-gradient(#5070E9 0%, #598DFD 100%);
		text-align: center;
		line-height: 56rpx;
		color: #fff;
		font-size: 24rpx;
		border-radius: 28rpx;
	}
}
</style>
